﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CodeEditor
{
    /// <summary>
    /// Eine ExceptionMessageBox, die Excpetions vernünftig darstellt
    /// </summary>
    public partial class ExceptionMessageBox : Form
    {
        /// <summary>
        /// Name der Exception
        /// </summary>
        String ExceptionName
        {
            get
            {
                return textBoxErrorMessage.Text;
            }
            set
            {
                textBoxErrorMessage.Text = value;
            }
        }

        /// <summary>
        /// Kurze Beschreibung der Exception
        /// </summary>
        String ExceptionDescription
        {
            get
            {
                return textBoxDescription.Text;
            }
            set
            {
                textBoxDescription.Text = value;
            }
        }

        /// <summary>
        /// Stapel, der Exception ausgelöst hat
        /// </summary>
        String StackTrace
        {
            get
            {
                return textBoxStackTrace.Text;
            }
            set
            {
                textBoxStackTrace.Text = value;
            }
        }


        /// <summary>
        /// Konstruktor
        /// </summary>
        /// <param name="ex">Ausgelöste Exception</param>
        public ExceptionMessageBox(Exception ex)
        {
            InitializeComponent();

            ExceptionName = ex.Source;
            ExceptionDescription = ex.Message;
            StackTrace = ex.StackTrace;
            this.ShowDialog();
        }

        /// <summary>
        /// Wird ausgelöst, wenn auf Schließen geklickt wird. Schließt die Messagebox
        /// </summary>
        /// <param name="sender">Button</param>
        /// <param name="e">Event Arguments</param>
        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }


    }
}
